﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronCommander.Utils
{
    public static class EnumEx
    {
        public static bool IsFlagSet<T>(T value, T flag)
            where T : struct
        {
            if (!typeof(T).IsEnum)
                throw new ArgumentOutOfRangeException("Enum expected");

            var longValue = Convert.ToInt64(value);
            var longFlag = Convert.ToInt64(flag);

            return (longValue & longFlag) == longFlag;
        }
    }
}
